<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="/res/back/css/base.css" rel="stylesheet" type="text/css" />
<link href="/res/third/bootstrap3/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="/res/common/js/jquery.1.9.1.min.js" type="text/javascript"></script>
<script src="/res/third/artDialog/jquery.artDialog.js" type="text/javascript"></script>
<script src="/res/third/validate/jquery.validate.js" type="text/javascript"></script>

<script type="text/javascript">
	function sosuo(){
		var lpath =location.pathname;
		var pageNo = 1;
		$("#soform").attr("action",lpath+"?pageNo="+pageNo);
		$("#soform").submit();
	}
	
	var fulldialog;
	function fullscreen(id,title){
		top.addTempTab("/purchase/v_enquiry_item.do?so_enquiryid="+id);
	}
	
	function changestatrecallback(){
		refresh();
	}
	var exceldialog=null;
	function uploaddialog(enquiryid,title){
		var param ={id:enquiryid,title:title};
		exceldialog = art.dialog.uploadFile("上传excel",{callback:"uploadcallback",params:JSON.stringify(param),userpath:"admin",extensions:"xls,xlsx"});
	}
	
	function uploadcallback(response,params){
		exceldialog.close();
		art.dialog.post({
			url:"/purchase/o_excel_update.do",
			data:{url:response.url,id:params.id},
			success:function(data){
				if(data.success){//更新成功
					setTimeout(function(){
						analysis(params.id,params.title);//分析excel
					},100)
				}else{
					alert(data.msg);
				}			
			}
		},"更新地址");
	}
	
	/* 分析excel */
	function analysis(id,title){
		var autodelete = 0;
		if($("#autodelete").is(":checked")){
			autodelete=1;
		}
		top.addTempTab("/purchase/o_retry.do?id="+id+"&autodelete="+autodelete);
	}
	
	/* 审核通过 */
// 	改变状态的提示页面
	function changeState(enquiryid ,prostate){
		art.dialog.load("请做出选择","/purchase/v_prostate_change.do",{enquiryid:enquiryid,prostate:prostate});
	}
	

</script>
</head>

<body>
	<div class="panel panel-info panel-content">
		<div class="panel-heading">
			<form id="soform" method="post">
				<table>
					<tr>
						<td class="w80 "><label for="so_prostate" class="center-block">项目状态:</label></td>
						<td class="w120 "><select class="form-control" id="so_prostate" name="so_prostate"> [#list states as code ]
								<option value="${code.index}" [#if so_prostate?? && so_prostate== code.index?string ]selected="selected" [#else]  [#if code.index==-1 ]selected="selected"[/#if] [/#if]  >${code.title}</option>
								[/#list]
						</select></td>

						<td>
							<div class="input-group">
								<input type="text" class="form-control" name="so_title" value='${so_title!}' placeholder="项目名称,发布商家"> <span class="input-group-btn">
									<button class="btn btn-default" type="button" onclick="sosuo()">搜索</button>
								</span>
							</div>
						</td>
						<td>
							&nbsp;&nbsp;&nbsp;&nbsp;
						</td>
						<td>
							<label>
								<input id="autodelete" type="checkbox"  value="1" checked="checked"  >分析时,某些情况下自动识别并去除无用列
							</label>	
						</td>
					</tr>
				</table>
			</form>
		</div>
		<table class="table table-hover table-bordered table-striped table-condensed">
			<thead>
				<tr>
					<th>#</th>
					<th>项目名称</th>
					<th>是否公开</th>
					<th>报价截止日期</th>
					<th>涉及系统</th>
					<th>发布时间</th>
					<!-- 						<th>设计清单</th> -->
					<th>涉及产品</th>
					<th>发布商家</th>
					<th>excel</th>
					<th>审核状态</th>
					<th>联系信息</th>
					<th>操作</th>
				</tr>
			</thead>
			[#list pagination.list as enquiry ]
			<tr>
				<td>${pagination.pageSize * (pagination.pageNo-1) + enquiry_index+1!}</td>
				<td>${enquiry.title!}</td>
				<td>[#if enquiry.pubtype?? ][#if enquiry.pubtype==1]公开[#else]不公开[/#if][#else]公开[/#if]</td>
				<td>[#if enquiry.deadline?? ]${enquiry.deadline?string("yyyy-MM-dd")!''}[/#if]</td>
				<td>${enquiry.fcatename!}</td>
				<td>[#if enquiry.pubdate??]${enquiry.pubdate?string("yyyy-MM-dd")!''}[/#if]</td> [#--
				<td>[#if enquiry.items?? ][#if enquiry.items?size ==0]无[#else]有[/#if][#else]无[/#if]</td>--]
				<td>[#if enquiry.items?? ]${enquiry.items?size}[#else]0[/#if]</td>
				<td>[#if enquiry.customer?? ]${enquiry.customer.company!}[/#if]</td>
				<td>[#if enquiry.excelpath?? && enquiry.excelpath!="" ]<a target="_blank" href="${enquiry.excelpath}">有<span class="glyphicon glyphicon-download-alt" aria-hidden="true"></span></a> <a
					target="_blank" href="/purchase/v_review.do?path=${enquiry.excelpath}">预览</a> [#else ]无[/#if]

				</td>
				<td>${enquiry.prostateName!}</td>
				<td>${enquiry.contacts!}/${enquiry.phone!}</td>
				<td>[#if enquiry.items?? && enquiry.items?size != 0 ]
					<button type="button" class="btn btn-xs btn-info" onclick="fullscreen(${enquiry.id!},'${enquiry.title!}')">询价单</button> 
						[#if enquiry.excelpath?? && enquiry.excelpath!="" ]
					<button type="button" class="btn btn-xs btn-danger" onclick="analysis(${enquiry.id!},'${enquiry.title!}')">重新分析</button> 
						[/#if] 
						[#else]
						[#if enquiry.excelpath?? && enquiry.excelpath!=""]
					<button type="button" class="btn btn-xs btn-danger" onclick="analysis(${enquiry.id!},'${enquiry.title!}')">分析</button> 
						[/#if] 
					[/#if]
					<button type="button" class="btn btn-xs btn-info" onclick="uploaddialog(${enquiry.id!},'${enquiry.title!}')">[#if enquiry.excelpath?? && enquiry.excelpath!="" ]重新[/#if]上传</button> [#if
					enquiry.prostate == 0 || enquiry.prostate == 3 ]
					<button type="button" class="btn  btn-xs  btn-success" onclick="changeState(${enquiry.id},1)">通过审核</button>
					<button type="button" class="btn  btn-xs   btn-default" onclick="changeState(${enquiry.id},2)">退回修改</button> 
					[#elseif enquiry.prostate == 1 ]
					<button type="button" class="btn   btn-xs  btn-default" onclick="changeState(${enquiry.id},2)">退回修改</button> [/#if ]

				</td>
			</tr>
			[/#list]
		</table>

		<div class="panel-footer">[@fenye p = pagination form = 'infoForm' /]</div>
	</div>

	[#--
	<div>[@upload_file id="uploader" fileNumLimit=1 /]</div>
	--]
</body>
</html>